package com.sentrix.auto.printercenter.infrastructure.config;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;

@Configuration
public class GuavaEventBusConfig {
    /**
     * 配置同步事件总线
     */
    @Bean(name = "sync-event-bus")
    public EventBus syncEventBus() {
        return new EventBus("sync-event-bus");
    }

    /**
     * 配置异步事件总线
     */
    @Bean(name = "async-event-bus")
    public EventBus asyncEventBus() {
        return new AsyncEventBus("async-event-bus", Executors.newFixedThreadPool(10));
    }
}
